package com.cnooc.aicv.lmapp.util;

import com.cnooc.aicv.lmapp.model.VideoAlarmInformation;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Date;

public class VideoAlarmToJsonExample {
    public static void main(String[] args) throws Exception {
        // 创建一个 VideoAlarmInformation 实例
        VideoAlarmInformation videoAlarmInfo = new VideoAlarmInformation();
        videoAlarmInfo.setAlarmId("12345");
        videoAlarmInfo.setAlarmType("火灾报警");
        videoAlarmInfo.setAlarmPictureBase64("base64编码...");
        videoAlarmInfo.setAlarmTime(new Date());
        videoAlarmInfo.setPlatformName("平台A");
        videoAlarmInfo.setRemark("这是一个测试报警");

        // 使用 Jackson 的 ObjectMapper 将对象转换成 JSON 字符串
        ObjectMapper mapper = new ObjectMapper();
        String jsonString = mapper.writeValueAsString(videoAlarmInfo);

        System.out.println(jsonString); // 输出 JSON 字符串
    }
}